import java.util.Scanner;
public class GuessNumber {
    public static void main(String[] args) {
        int answer = (int) (Math.random() * 100 + 1);
        int chance = 7;
        while (chance > 0) {
            System.out.println("请猜1个1-100之间的整数（含1和100)" + "你还有" + chance + "次机会");
            Scanner scan = new Scanner(System.in);
            String again;
            do {
                int guess=scan.nextInt();
                if (guess>answer){
                    System.out.println("猜大了");
                }else if(guess<answer){
                    System.out.println("猜小了");
                }else {
                    System.out.println("恭喜你！猜对了！");
                    break;
                }
                chance=chance-1;
                if (chance<=0){
                    System.out.println("糟糕机会用完啦");
                }
                System.out.println("继续吗？(y/n)");
                again=scan.next();
            } while
            (again.equalsIgnoreCase("y"));
        }
    }
}